home *** CD-ROM | disk | FTP | other *** search
- 'CFGTEXT.TXT
- ' Routines to configure a text box for max length and upper/lower case translation
- ' and password hiding
- '
- ' These routines also appear to work fine with QEVB (Pioneer) controls
- '
- ' Jim McClure
- ' QED, Inc.
- ' 9/16/92
- ' CSID = 76666,1303
- ' or jamcclure@qed.com from Internet
-
-
- '---------
- 'Win API Calls
- 'Put these in your Global module
- '---------
- Declare Function GetWindowLong& Lib "User" (ByVal hWd%, ByVal nIndex%)
- Declare Function SetWindowLong& Lib "User" (ByVal hWd%, ByVal nIndex%, ByVal dwNewLong&)
- Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
-
- Global Const GWL_STYLE = -16
- Global Const ES_UPPERCASE = &H8&
- Global Const ES_LOWERCASE = &H10&
- Global Const ES_PASSWORD = &H20&
-
- Global Const WM_USER = &H400
- Global Const EM_LIMITTEXT = WM_USER + 21
- Global Const EM_SETPASSWORDCHAR = WM_USER + 28
-
-
- '----------
- 'Get the VBHWND.ZIP file from Lib 1 and use the CTLHWND DLL in it
- '----------
- Declare Function ControlhWnd% Lib "CTLHWND" (Ctl as Control)
-
-
- '----------
- 'Routine to configure a text box
- 'Put this routine in a general module
- '----------
- Sub ConfigTextBox (t As Control, Style As Long, MaxLen As Integer)
- Dim CtlStyles As Long, NewStyles As Long, Ok As Long
- Dim tWnd As Integer
-
- 'Get handle to text box control
- tWnd = ControlhWnd(t)
-
- 'Get current style settings
- CtlStyles = GetWindowLong(tWnd, GWL_STYLE)
-
- 'Add in new styles
- 'If you want to be able to "toggle" styles, use XOR here and send '1' bits for styles
- NewStyles = CtlStyles Or Style
-
- 'Set new style
- CtlStyles = SetWindowLong(tWnd, GWL_STYLE, NewStyles)
-
- 'Set type of password char
- 'Just use default '*', or could pass in a char for use
- If (NewStyles And ES_PASSWORD) > 0 Then
- Ok = SendMessage(tWnd, EM_SETPASSWORDCHAR, Asc("*"), 0&)
- End If
-
- 'Now set limit on length of text
- '****THESE LINES WERE OMITTED ON THE INITIAL UPLOAD!****
- If MaxLen > 0 Then
- Ok = SendMessage(tWnd, EM_LIMITTEXT, MaxLen, 0)
- End If
- End Sub
-
-
- '----------
- 'Sample calls to ConfigTextBox
- '----------
- Sub Form_Load()
- ConfigTextBox Text1, ES_UPPERCASE, 10
- ConfigTextBox Text2, ES_UPPERCASE Or ES_PASSWORD, 10
- 'etc...
- End Sub
-